<?php defined( '_SYS' ) or die( 'No direct script access allowed' );?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title><?php echo $this->title; ?></title>
<?php echo $this->headData; ?>
</head>
<body>
	<div id="toolbar-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m" >
			<div class="toolbar" id="toolbar">
				<table class="toolbar">
						<td class="button" id="toolbar-new">
							<a href="#" onclick="javascript:submitbutton('add')" class="toolbar">
								<span class="icon-32-new" title="New">
								</span>
							<?php echo C_text::_('New');?>
							</a>
						</td>
						<td class="button" id="toolbar-edit">
							<a href="#" onclick="javascript:if(document.adminForm.boxchecked.value==0){alert('<?php echo C_text::_('Tip9');?>');}else{ submitbutton('edit')}" class="toolbar">
								<span class="icon-32-edit" title="Edit">
								</span>
							<?php echo C_text::_('Edit');?>
							</a>
						</td>
						<td class="button" id="toolbar-delete">
							<a href="#" onclick="javascript:if(document.adminForm.boxchecked.value==0){alert('<?php echo C_text::_('Tip8');?>');}else{  if(confirm('<?php echo C_text::_('Tip12');?>')) submitbutton('remove')}" class="toolbar">
								<span class="icon-32-delete" title="Delete">
								</span>
							<?php echo C_text::_('Delete');?>
							</a>
						</td>						
				</table>
			</div>
			<div class="header icon-48-user"><?php echo C_text::_('u_ToolBox').' '.C_text::_('Users');?></div>	
			<div class="clr"></div>		
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>	
	<div id="submenu-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
	 	</div>
		<div class="m">

			<div class="submenu-box">
				<div class="submenu-pad">
					<ul id="submenu" class="configuration"> 
						<li><a class="active" href="<?php echo WEBSELF; ?>/user/display/option/users"><?php echo C_text::_('Users');?></a></li>
						<li><a href="<?php echo WEBSELF; ?>/user/display/option/groups"><?php echo C_text::_('Groups');?></a></li>
					</ul>

					<div class="clr"></div>
				</div>
			</div>
		<div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>	
	<div class="clr"></div>
	<?php if($this->message) echo $this->message;?>
	<div id="element-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m">
			<form action="<?php echo WEBSELF; ?>/user" method="post" name="adminForm">
				<table>
					<tr>
						<td width="100%">
							<?php echo C_text::_( 'Filter' ); ?> :
							<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="if(document.getElementById('limitstart')) document.getElementById('limitstart').value=0;document.adminForm.submit();" />
							<button onclick="if(document.getElementById('limitstart')) document.getElementById('limitstart').value=0;this.form.submit();"><?php echo C_text::_( 'Go' ); ?></button>
							<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_group').value='0';this.form.submit();"><?php echo C_text::_( 'Reset' ); ?></button>
						</td>
						<td nowrap="nowrap">
							<?php echo C_HTML::_( 'access.usergroup','filter_group',$this->lists['filter_group'],'class="inputbox" size="1" onchange="document.adminForm.submit( );"');?>
						</td>
					</tr>
				</table>

				<table class="adminlist" cellpadding="1">
					<thead>
						<tr>
							<th width="2%" class="title">
								#
							</th>
							<th width="3%" class="title">
								<input class="cb" type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->admin_list); ?>);" />
							</th>
							<th class="title">
								<?php echo C_html::_('grid.sort',   'Name', 'a.admin_name', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
							<th width="15%" class="title" >
								<?php echo C_html::_('grid.sort',   'Username', 'a.admin_id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
							<th width="5%" class="title" nowrap="nowrap">
								<?php echo C_text::_( 'Logged In' ); ?>
							</th>
							<th width="5%" class="title" nowrap="nowrap">
								<?php echo C_html::_('grid.sort',   'Enabled', 'a.block', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
							<th width="15%" class="title">
								<?php echo C_html::_('grid.sort',   'Group', 'admin_type', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
							<th width="15%" class="title">
								<?php echo C_html::_('grid.sort',   'E-Mail', 'a.admin_email', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
							<th width="10%" class="title">
								<?php echo C_html::_('grid.sort',   'LastVisit', 'a.admin_modify_date', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
							<th width="1%" class="title" nowrap="nowrap">
								<?php echo C_html::_('grid.sort',   'ID', 'a.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
							</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="10">
								<?php echo $this->pagination->getListFooter(); ?>
							</td>
						</tr>						
					</tfoot>
					<tbody>
		<?php
			$k = 0;
			$db = &$SYS->loader->getDBO();			
			for ($i=0, $n=count( $this->admin_list ); $i < $n; $i++)
			{
				$row =& $this->admin_list[$i];
				$db->setQuery('select userid from '.$db->_table_prefix.'session where time>'.time().' and userid='.$row['id']);
				$row['loggedin']=$db->loadResult()==null?0:1;
				$img 	= $row['block'] ? 'publish_x.png' : 'tick.png';
				$task 	= $row['block'] ? 'unblock' : 'block';
				$alt 	= $row['block'] ? C_text::_( 'Enabled' ) : C_text::_( 'Blocked' );
				$row['admin_type'] = C_html::_('access.user_to_usergroup',$row['gid']);
				if ($row['admin_modify_date'] == "") {
					$lvisit = C_text::_( 'Never' );
				} else {
					$lvisit	= $row['admin_modify_date'];
				}
			?>
			<tr class="<?php echo "row$k"; ?>">
				<td>
					<?php echo $i+1+$this->pagination->limitstart;?>
				</td>
				<td>
					<?php echo C_html::_('grid.id', $i, $row['id'] ); ?>
				</td>
				<td>
						<?php echo $row['admin_name']; ?>
				</td>
				<td>
					<?php echo $row['admin_id']; ?>
				</td>
				<td align="center">
					<?php echo $row['loggedin'] ? '<img src="'.$this->imagePath.'tick.png" width="16" height="16" border="0" alt="" />': ''; ?>
				</td>
				<td align="center">
					<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')">
						<img src="<?php echo $this->imagePath.$img;?>" width="16" height="16" border="0" alt="<?php echo $alt; ?>" /></a>
				</td>
				<td>
					<?php echo $row['admin_type']; ?>
				</td>
				<td>
					<a href="mailto:<?php echo $row['admin_email']; ?>">
						<?php echo $row['admin_email']; ?></a>
				</td>
				<td nowrap="nowrap">
					<?php echo $lvisit; ?>
				</td>
				<td>
					<?php echo $row['id']; ?>
				</td>
			</tr>
			<?php
				$k = 1 - $k;
				}
			?>
		</tbody>
	</table>

	<input type="hidden" name="option" value="users" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo C_HTML::_( 'form.token' ); ?>
</form>
</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>
<center>
	Powered by <b><a href='http://www.metinfo.cn' target='_blank'>MetInfo</a></b> ©2008- <?php echo date('Y',time());?>&nbsp;<a href='http://www.metinfo.cn' target='_blank'>www.MetInfo.cn</a>
</center>
<?php echo $this->js; ?>
</body>
</html>